from pydub import AudioSegment
from gtts import gTTS

# 生成文本到语音的 MP3 文件
text = "This is a test audio generated for Whisper model."
tts = gTTS(text)
tts.save("test_audio.mp3")

# 通过 pydub 读取并播放音频 (可选)
audio = AudioSegment.from_mp3("test_audio.mp3")
audio.export("output_audio.mp3", format="mp3")

print("MP3 audio file generated as 'test_audio.mp3'")
